import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/main_page/collect/view/cook_item_cell.dart';
import 'package:flutter_douban/main_page/home/detail/page/cook_detail_page.dart';
import 'package:flutter_douban/model/cook_info_model.dart';

class MotherFoodView extends StatefulWidget {
  final List<CookInfoModel> cookList;
  const MotherFoodView({Key? key, required this.cookList}) : super(key: key);

  @override
  _MotherFoodViewState createState() => _MotherFoodViewState();
}

class _MotherFoodViewState extends State<MotherFoodView> {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      margin: EdgeInsets.only(top: 80),
      child: ListView.builder(
        itemCount: widget.cookList.length,
        shrinkWrap: true, //增加
        itemBuilder: (BuildContext context, int index) {
          if (index == 0) {
            return _headerView(widget.cookList[index]);
          } else {
            return CookItemCell(model: widget.cookList[index],);
          }
        },
      ),
    );
  }

  /// 头视图
  Widget _headerView(CookInfoModel model) {
    return Container(
      color: Colors.white,
      alignment: Alignment.topLeft,
      margin: EdgeInsets.only(left: 15, top: 10, right: 15),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            model.n!,
            strutStyle: StrutStyle(
                forceStrutHeight: true, height: 1, leading: 0.35),
            style: TextStyle(
              fontSize: 13,
              color: AppColors.qianTextColor,
            ),
          ),
          SizedBox(
            height: 30,
          ),
          Text(
            '推荐菜谱',
            overflow: TextOverflow.ellipsis,
            style: TextStyle(
              fontSize: 24,
              fontWeight: FontWeight.bold,
              color: AppColors.black,
            ),
          ),
        ],
      ),
    );
  }
}
